# Definition for a binary tree node.
class TreeNode:
    def __init__(self, val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right
    
    def bfs_show(self):
        s = [self.val]
        trees = [self.left, self.right]
        while any(trees):
            if trees[0] != None:
                s.append(trees[0].val)
                trees.append(trees[0].left)
                trees.append(trees[0].right)
            else:
                s.append(None)
            trees = trees[1:]
        return s
    
    def preorder(self):
        res = [self.val]
        if self.left:
            res += self.left.preorder()
        if self.right:
            res += self.right.preorder()
        return res
    
    def inorder(self):
        res = [self.val]
        if self.left:
            res = self.left.inorder() + res
        if self.right:
            res += self.right.inorder()
        return res
    
    def postorder(self):
        res = [self.val]
        if self.left:
            res = self.left.postorder() + res
        if self.right:
            res = self.right.postorder() + res
        return res

def bfs_load(l):
    if l:
        root = TreeNode(l[0])
        l = l[1:]
        queue = [root]
        while l:
            if l[0] is not None:
                queue[0].left = TreeNode(l[0])
                queue.append(queue[0].left)
            l = l[1:]
            if l:
                if l[0] is not None:
                    queue[0].right = TreeNode(l[0])
                    queue.append(queue[0].right)
                l = l[1:]
                queue = queue[1:]
            else:
                break
        return root